home *** CD-ROM | disk | FTP | other *** search
/ Univers Mac Interactif 53 / Univers Mac Interactif - Issue 53.iso / UNIVERS MAC 53 / Newtonissimo / don't-ask-1.0 folder / dontask.nwt < prev    next >
Text File  |  1995-06-07  |  10KB  |  237 lines

  1. Notes
  2. {labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
  3. //ERASE! remove initial // to erase existing entries in this folder first
  4.  
  5. dontask.nwt -- Slurpee format
  6. 6/7/95
  7. Copyright 1995 S. Weyer.  All Rights Reserved Worldwide.
  8.  
  9. Keywords: keyboard, prompt, source, Newt
  10.  
  11. Don't Ask (Don't Tell) is a simple, tiny app (autopart) that adds a button (at
  12. lower left) in the standard keyboard so that you can turn off/on the "Do you
  13. want to add..." prompt, which you may find annoying or sometimes desirable...
  14.  
  15. When dot is hollow (default), words pass through to the dictionary prompt.
  16. When dot is solid, the dictionary prompt does not appear (it's blocked/overridden).
  17.  
  18. This Newt source file (dontask.nwt) and the associated Newt-generated
  19. package (DontAsk.pkg) are shareware ($5) and may be distributed freely as
  20. long as both files are included and unmodified.  You are free to make
  21. modifications for your own use.
  22.  
  23. For your convenience, I have attached a package generated by the Newt
  24. Development Environment* so that you don't have to compile & save this
  25. yourself -- just install using NCK, Package Installer or a shareware
  26. downloader. If you would like to build or modify the Don't Ask application,
  27. you can use Newt (3.0 or greater) (see directions at end); you can avoid
  28. re-entering the source by transferring dontask.nwt with a utility such as
  29. Slurpee (1.5).
  30.  
  31. *Newt is an environment for developing applications using NewtonScript and
  32. saving as packages directly on your Newton (you can also use a PC or Mac for
  33. source editing and application debugging). Newt is shareware -- registered
  34. users receive files containing current releases, additional packages, 165+
  35. source examples, and a 80+ pp. (paper or Acrobat) manual describing Newt
  36. features and NewtonScript syntax and functions. For more information,
  37. browse http://www.netaxs.com/~weyer, or consult the Newt FAQ on AOL,
  38. eWorld, AppleLink, Compuserve, newton.uiowa.edu or ftp.amug.org
  39. (or send me email: weyer@netaxs.com).
  40.  
  41. Disclaimers: Don't Ask relies on undocumented behavior of the built-in
  42. keyboard so it is not guaranteed to work on future Newtons or software
  43. configurations. It appears not to interfere with the Graffiti kbd patch --
  44. either in setup behavior or location (Graffiti button appears on right,
  45. DontAsk on left). If you're aware of keyboard related conflicts, let me know
  46. and I will contact other developers to see if we can coordinate our patches.
  47.  
  48. DontAsk generally installs & removes itself properly.  However, if it is
  49. installed on a card and you remove the card while the keyboard is open, you
  50. will get a "Newton Still Needs the Card" message (just close the kbd first;
  51. or install DontAsk in internal; or we could modify the button to consume more
  52. heap).
  53.  
  54. Implementation notes: this could be even simpler -- don't add a button, just
  55. always turn off the prompt -- but it seemed to me that there might be
  56. occasions where you might want to turn prompting back on.  It could be more
  57. complex -- behavior controlled via a Preference panel, but that would
  58. require many taps to switch back and forth.
  59.  
  60. You can send questions, feature requests, and registrations for DontAsk ($5)
  61. or Newt ($45) [please include your email address, if any] to:
  62.  
  63. Steve Weyer
  64. 17 Timber Knoll Drive
  65. Washington Crossing, PA 18977-1052
  66. Internet: weyer@netaxs.com
  67. http://www.netaxs.com/~weyer
  68. America Online/eWorld/NewtonMail: SteveWeyer
  69. Compuserve: 74603,2051
  70.  
  71. Since DontAsk is such a simple app, I don't have any major enhancments planned.
  72. If you do register, you'll encourage me to write, release (and inform you
  73. about) other utilities and source examples.
  74. ----------
  75. init
  76. //:init()
  77. begin
  78.     :DefConst('kSize,5); // dot size
  79. end
  80. ----------
  81. DontAsk
  82. //:doObj('build,'DontAsk)
  83. //:saveApp(DontAsk)
  84. {// a simple "button".
  85. // a checkbox might be nicer but there's no really no room in kbd
  86. // and adding a Preference panel seems very inconvenient to user
  87. // note: constants can be defined symbolically with optional viewcnst.pkg plug-in
  88.  
  89. viewclass: clView, // just a vanilla view
  90. viewFlags: 513,    // vClickable + vVisible
  91. viewBounds: RelBounds(22,-7,kSize,kSize), // left,top,width,height. left&top relative to left&bottom, between Dict icon & Option
  92. viewJustify: 128,  // vjParentBottomV (left, bottom aligned)
  93. viewDrawScript: func()
  94.     :DrawShape(MakeOval(0,0,kSize,kSize), // left,top,right,bottom
  95.         {transferMode: 0, // modeCopy
  96.         fillPattern: if askWords
  97.             then 0  // vfFillWhite
  98.             else 5, // vfFillBlack
  99.             }),
  100.  
  101. viewClickScript: func(unit)
  102.     begin
  103.         askWords := not askWords; // toggle in parent (alphakeyboard)
  104.         :dirty(); // redraw. returns TRUE
  105.     end,
  106.  
  107. _package: {
  108.     version: 10,
  109.     copyright: "\u00A9\u 1995, S. Weyer",
  110.     devSignature: "TKnollSys", // appSymbol => DontAsk:TKnollSys 
  111.  
  112.     //installScript -- add these separately for editing convenience
  113.     //removeScript
  114.     //partData -- this is an autopart
  115.     },
  116. }
  117. ----------
  118. DontAsk._package.installScript
  119. //:installApp(DontAsk,true)
  120. func(partFrame,removeFrame)
  121. begin
  122.     local slot,val, kbd := GetRoot().alphaKeyboard;
  123.     // we could check visibility & redo children. simpler just to close it...
  124.     kbd:close();
  125.  
  126.     // copy some values into built-in keyboard VIEW
  127.     // and stash slots in removeFrame for later cleanup
  128.     foreach slot,val in partFrame.partData
  129.     do begin
  130.         slot := EnsureInternal(slot);
  131.         removeFrame.(slot) := kbd.(slot) := val;
  132.         end;
  133.  
  134.     // button appears next time kbd opened
  135. end
  136. ----------
  137. DontAsk._package.removeScript
  138. //:installApp(DontAsk,nil)
  139. func(removeFrame)
  140. begin
  141.     local slot, val, kbd := GetRoot().alphaKeyboard;
  142.     // we could check visibility & redo children. simpler just to close it...
  143.     kbd:close(); // if kbd still open & card is removed, then "Newton Still Needs the Card" !
  144.  
  145.     // remove slots we added in installScript
  146.     foreach slot,val in removeFrame
  147.     do RemoveSlot(kbd,slot);
  148. end
  149. ----------
  150. DontAsk._package.partData
  151. {// slots to add to the keyboard view
  152.  
  153. // this is set each system reset/card insertion; could store in a system preference?
  154. askWords: true, // prompt as usual (default). modified in DontAsk.viewClickScript. used in kbd.keywordScript & DontAsk.viewDrawScript
  155.  
  156. dontAskTemplate: DontAsk._proto, // the "button" template, to be added as a child in kbd.viewSetupChildrenScript
  157.  
  158. keywordScript: func(x)
  159.     if askWords
  160.     then inherited:keywordScript(x) // default (prompt) behavior
  161.     else NIL, // don't prompt
  162.  
  163. viewSetupChildrenScript: func()
  164.     if shrunken // only do this if prompt isn't being displayed
  165.     then begin
  166.         // I think Graffiti patch adds a viewSetupFormScript method 
  167.         // and sets stepChildren there, so this seems to peacefully coexist...
  168.         if not stepChildren
  169.         then stepChildren := [];
  170.         AddArraySlot(stepChildren,dontAskTemplate);
  171.         end,
  172. }
  173. ----------
  174. I will provide a few suggestions here on how to modify, build & test this
  175. application. Of course, I would recommend registering for Newt to obtain more
  176. documentation and examples...
  177.  
  178. - transfer source to the Notepad (use Slurpee, NCK or ...)
  179.  
  180. - install Newt 3.0 & NewtPack.  note: if you have an Original MessagePad with
  181. pre-1.3 ROMs, you won't be able to save this app as a package with Newt 3.0;
  182. saving packages on OMP works in 3.1 (but this may not be publicly available yet)
  183.  
  184. - if you installed the DontAsk:TKnollSys package, remove it via Card:Remove Software;
  185. or, use Remove Package command (under action button) once you are in Newt --
  186. otherwise, you won't be able to install&test during development (though you could
  187. just build & save(replace)).
  188.  
  189. - start Newt. select folder with source (default is Unfiled)
  190.  
  191. - make any edits, for example:
  192.   change location of button, RelBounds(21,-8,kSize,kSize) in DontAsk's viewBounds slot // move left & up 1
  193.   change shape of button, MakeRect instead of MakeOval in DontAsk's viewDrawScript method
  194.   change size of button, :DefConst('kSize,7) in init method
  195.     to redefine constant. tap Expr. select :init(). tap Eval
  196.   change fill of button, 4 (for vfFillDkGray) instead of 5 (for vfFillBlack)
  197.     in DontAsk's viewDrawScript method
  198.   so, now button would be a 7x7 square instead of 5x5 circle
  199.  
  200. - build application:  tap Expr. select :doObj('build,'DontAsk).  Eval
  201.  
  202. - install application temporarily (run its installScript, etc.)
  203.   tap Expr.  select :installApp(DontAsk,true). Eval
  204.  
  205. - double-tap in text area to get standard keyboard.
  206.   (note: Newt's keyboard (via icon) is a different keyboard object, so does
  207.   not have this button currently).
  208.  
  209. - optional. tap Expr. select :installApp(DontAsk,nil). Eval
  210.   to un-install app.  (this isn't strictly necessary since build or save
  211.   ensure it is un-installed).
  212.  
  213. - possibly iterate through additional edit/build/install cycles.
  214.  
  215. - to save package, tap Expr. select :saveApp(DontAsk). Eval
  216.  
  217. - exit Newt. double-tap to see keyboard.
  218.  
  219. - to confirm installScript/removeScript behavior
  220.   close keyboard
  221.   unlock or remove card
  222.   double-tap to get keyboard (no button should be present)
  223.   lock or insert card
  224.   keyboard closes (if open)
  225.   double-tap for keyboard (button should be present)
  226.  
  227. - congratulations! you have just created, tested and installed a custom autopart
  228.  
  229. - to give the new package to your friends:
  230.   backup Newton using NCK.
  231.   use Extract Package application (see www.netaxs.com/~weyer for URLs for Mac
  232.   and Windows versions) to extract package from NCK bacup file. (Windows version
  233.   may display package name generically as "package0xxxx" -- you can compare size
  234.   of file with package in Newton's Remove Software/Package menu)
  235. ---------
  236. BYE!
  237.